← Back
Editing: protect-ext.js
import{at as e,o as a,K as t,aj as l,al as s,j as n,k as o,a0 as i,W as u,h as p,b as r,e as c}from"./utils-lib.js?v=1765440387";import{c as d,r as m,k as h,e as v,g as f,B as _,F as w,p as x,G as y,H as g,x as b,q as j,v as V,M as k,C,P as q,A as D,y as U,a$ as O,U as z,am as E,D as R,aj as M,ak as S,aa as A,a8 as F,w as H}from"./base-lib.js?v=1765440387";import{_ as I}from"./index93.js?v=1765440387";import{_ as J}from"./index113.js?v=1765440387";import{a as N,u as P,c as T}from"./column.js?v=1765440387";import{o as B,r as G}from"./useController6.js?v=1765440387";import{u as K}from"./useStore3.js?v=1765440387";import{gd as W,gq as $,gr as L,gs as Q,gt as X,bE as Y,fa as Z}from"./site.js?v=1765440387";import{_ as ee}from"./masker.vue_vue_type_script_setup_true_lang.js?v=1765440387";import"./__commonjsHelpers__.js?v=1765440387";import"./index94.js?v=1765440387";import"./validator.js?v=1765440387";import"./index120.js?v=1765440387";import"./index.vue_vue_type_style_index_0_scoped_b3c4124c_lang.js?v=1765440387";const ae={class:"flex gap-col-1rem"},te={class:"p-2rem"},le=c(d({__name:"protect-ext",props:{compData:{default:{}}},setup(c,{expose:d}){const le=r(),{siteInfo:se}=K(),ne=m("file"),oe=m(),ie=m(!1),ue=m(""),pe=m(!1),re=m({}),ce=m([]),de=m([]),me=m(!1),he=m(!1),ve=m(),fe=m(!1),_e=h({sites:[],list:[]}),we=h({sites:[{required:!0,message:"请选择同步配置",trigger:"blur"}]}),xe=m([{label:"受保护的文件类型",name:"file",lazy:!0,render:()=>v("span",null,null)},{label:"受保护的文件目录",name:"directory",lazy:!0,render:()=>v("span",null,null)}]),ye=f(()=>"file"===ne.value?[{content:"所谓文件类型是指文件名结尾的字符串,不一定是扩展名"},{content:v(w,null,[_("例如"),v("code",null,[_(".php")]),_(","),v("code",null,[_(".html")]),_(","),v("code",null,[_(".js?v=1765440387")]),_(","),v("code",null,[_("index.php")]),_("等")])},{content:v(w,null,[_("例1:"),v("code",null,[_(".php")]),_("匹配:"),v("code",null,[_("./1.php")]),v("code",null,[_("./test/2.php")]),_("不匹配:"),v("code",null,[_("./1.php/1.txt")])])},{content:v(w,null,[_("例2:"),v("code",null,[_("index.php")]),_("匹配:"),v("code",null,[_("./index.php")]),v("code",null,[_("./test/index.php")]),v("code",null,[_("./abc_index.php")]),_("不匹配:"),v("code",null,[_("./index.php.tar.gz")])])}]:[{content:"支持以下4种方式"},{content:v(w,null,[_("1、完整文件路径,如:"),v("code",null,[_("/www/wwwroot/test/123.php")])])},{content:v(w,null,[_("2、相对于网站的相对路径,如:全路径是"),v("code",null,[_("/www/wwwroot/test/app/123.php")]),_("相对路径"),v("code",null,[_("./app/123.php")])])},{content:v(w,null,[_("3、指定目录下的所有文件,如:"),v("code",null,[_("/www/wwwroot/test/app/*")]),_("相对路径"),v("code",null,[_("./app/*")])])},{content:v(w,null,[_("4、指定目录下的指定文件类型,如:"),v("code",null,[_("/www/wwwroot/test/app/*.php")]),_("相对路径"),v("code",null,[_("./app/*.php")])])},{content:v("span",{class:"text-danger"},[_("注意,已经在【受保护的文件类型】中被包含的文件无需专门设置规则")])}]),ge=[{content:v(w,null,[_("【一键应用】将当前网站已配置的"),v("span",{class:"text-danger"},[_("排除目录")]),_(","),v("span",{class:"text-danger"},[_("防护文件")]),_(",同步配置到其他网站")])}],be=async(e,a,t,l)=>{const{label:s,value:n}=l,o=async(e,a)=>{const t=new Map([["open",L],["close",L],["delete",X]]),{exts:l}=e,{pid:s,path:o}=re.value,i=t.get(n);switch(n){case"open":case"close":if(i){return i({path_id:s,exts:l,release:"open"!==n?1:0})}case"delete":if(i){return i({path_id:s,exts:l,path:o})}}};await e({title:"批量".concat(s),content:"批量".concat(s,",是否继续操作?"),column:[{label:"".concat("file"===ne.value?"文件类型":"文件全路径 或 相对路径"),prop:"exts"},T()],onConfirm:async()=>(await a(o),je(),!1)})},je=async(a=!1)=>{try{a&&(ie.value=!0);const{data:e}=await W({path:se.value.path});let t=[];if(e.hasOwnProperty("status")){re.value=e;let a=e.black_exts||[],l=e.white_exts||[];null==a||a.forEach(e=>{t.push({exts:e,limit_status:1})}),null==l||l.forEach(e=>{t.push({exts:e,limit_status:0})})}ce.value=t.filter(e=>"file"===ne.value?-1===e.exts.indexOf("/"):-1!==e.exts.indexOf("/"))}catch(t){e(t)}finally{a&&(ie.value=!1)}},Ve=async()=>{if(""===ue.value)return le.error("文件类型不能为空");try{const e=await $({path_id:re.value.pid,path:re.value.path,exts:ue.value});le.request(e),e.status&&(ue.value="",je())}catch(e){}},ke=async(e,l)=>{try{e.limit_status=l?1:0,await a({title:"".concat(l?"开启":"关闭","【").concat(e.exts,"】"),content:"".concat(l?"开启该受保护文件类型后,该类型后缀文件将被保护,是否继续?":"关闭该受保护文件类型后,该类型后缀文件将不被保护,是否继续?"),icon:"warning"});(await t({loading:"正在设置保护文件状态,请稍后...",request:L({path_id:re.value.pid,exts:e.exts,release:l?0:1}),message:!0})).status&&je()}catch(s){"cancel"===s&&(e.limit_status=l?0:1)}},Ce=async()=>{const e=await t({loading:he,request:Z(),data:Array});_e.list=e},qe=async()=>{var a;await ve.value.validate();try{let e={};de.value.forEach(a=>{e[a.exts]=a.limit_status});let t={site_ids:JSON.stringify(_e.sites),exts:JSON.stringify(e)};const l=await Q(t);me.value=!1,B({title:"批量同步到其他站点",resultData:null==(a=l.data)?void 0:a.map(e=>({name:e.name,status:"同步成功"===e.msg,msg:e.msg})),resultTitle:"批量同步到其他站点操作",showMult:!1})}catch(t){e(t)}},De=async e=>{await a({title:"删除受保护的文件类型【"+e.exts+"】",content:"删除受保护的文件类型后,文件名以该后缀结尾的文件将失去保护,是否继续操作?",icon:"warning"});(await t({loading:"正在删除受保护的文件类型,请稍后...",request:X({path_id:re.value.pid,path:re.value.path,exts:e.exts}),message:!0})).status&&je()},Ue=async a=>{var t;try{let e={path_id:re.value.pid,exts:a.exts,row:10,p:1,pid:re.value.pid};const{data:s}=await Y(e);(null==(t=s.data)?void 0:t.length)?G({title:"受保护的文件类型【".concat(a.exts,"】日志"),row:a,data:s,params:{...e,total:l(s.page)}}):le.error("暂无日志")}catch(s){e(s)}},Oe=e=>{ue.value="",ne.value=e,ze.value[1].label="file"===e?"文件类型":"文件全路径 或 相对路径",je()},ze=z([N(),{prop:"exts",label:"文件路径"},{prop:"limit_status",label:"状态",render:(e,a)=>{let t=1===e.limit_status;return v(E,{size:"small",modelValue:t,"onUpdate:modelValue":e=>t=e,onChange:a=>ke(e,a)},null)}},P([{title:"日志",onClick:Ue},{title:"删除",onClick:De}])]),Ee=[{label:"开启受保护文件类型",value:"open",event:be},{label:"关闭受保护文件类型",value:"close",event:be},{label:"同步到其他站点",value:"sync",event:async(e,a,t,l,s)=>{de.value=t.value,_e.sites=[],me.value=!0,Ce(),H(()=>me.value,e=>{e||s()})}},{label:"删除受保护文件类型",value:"delete",event:be}];return x(()=>{je(!0)}),d({init:()=>{je(!0)}}),(e,a)=>{var t;const l=s,r=n,d=R,m=J,h=o,f=i,x=I,z=u,E=M,H=S,N=A,P=F,T=p,B=y("bt-loading");return g((j(),V("div",null,[(null==(t=b(re))?void 0:t.path)?C("",!0):(j(),k(ee,{key:0,compData:{...c.compData,init:je}},null,8,["compData"])),v(l,{ref:"tamperRef",type:"",modelValue:b(ne),"onUpdate:modelValue":a[0]||(a[0]=e=>q(ne)?ne.value=e:null),options:b(xe),onChange:Oe},null,8,["modelValue","options"]),v(x,null,{"header-left":D(()=>[U("div",ae,[v(r,{modelValue:b(ue),"onUpdate:modelValue":a[1]||(a[1]=e=>q(ue)?ue.value=e:null),width:"30rem",placeholder:"文件类型"},null,8,["modelValue"]),v(d,{type:"primary",onClick:Ve},{default:D(()=>[...a[4]||(a[4]=[_("添加",-1)])]),_:1})])]),"header-right":D(()=>[v(m,{onRefresh:je})]),content:D(()=>[g(v(h,{ref_key:"protectTableRef",ref:oe,column:b(ze),"max-height":360,data:b(ce)},null,8,["column","data"]),[[B,b(pe)]])]),"footer-left":D(()=>[v(f,{"table-ref":b(oe),options:b(Ee)},null,8,["table-ref","options"])]),"footer-right":D(()=>[...a[5]||(a[5]=[])]),_:1}),v(z,{class:"ml-2rem mt-2rem tamper-help-info","list-style":"disc",options:b(ye)},null,8,["options"]),v(T,{title:"批量同步到其他站点",modelValue:b(me),"onUpdate:modelValue":a[3]||(a[3]=e=>q(me)?me.value=e:null),area:50,"show-footer":"",onConfirm:qe},{default:D(()=>[U("div",te,[g((j(),k(P,{ref_key:"applyFormRef",ref:ve,model:b(_e),rules:b(we),disabled:b(fe)},{default:D(()=>[v(N,{label:"同步站点",prop:"sites"},{default:D(()=>[v(H,{modelValue:b(_e).sites,"onUpdate:modelValue":a[2]||(a[2]=e=>b(_e).sites=e),multiple:"","collapse-tags":"",class:"w-30rem",placeholder:"请选择站点"},{default:D(()=>[(j(!0),V(w,null,O(b(_e).list,e=>(j(),V(w,null,[e.id!==b(se).id?(j(),k(E,{key:e.id,label:e.rname,value:e.id},null,8,["label","value"])):C("",!0)],64))),256))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model","rules","disabled"])),[[B,b(he)]]),v(z,{"list-style":"disc",class:"mt-2rem ml-2rem",options:ge})])]),_:1},8,["modelValue"])])),[[B,b(ie)],[B,"正在获取站点防篡改信息,请稍侯","title"]])}}}),[["__scopeId","data-v-35f00a47"]]);export{le as default};
Save File
Cancel